<%@ page import="com.oval.util.JspHelper" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oval.foundation.metadata.workflow.*" %>
<%@ page import="com.oval.foundation.util.Constants" %>


<%! public String showParameters(Iterator it, boolean showAlias)
    {
      StringBuffer stb = new StringBuffer(1024);
      String widthComponent = "width=\"33%\"";
      if(showAlias)
        widthComponent = "width=\"25%\"";
      stb.append("<tr class=\"td_bg_row\">\n");
      stb.append("<td class=\"td_center\"");
      stb.append(widthComponent);
      stb.append(">Name</td>\n<td class=\"td_center\"");
      stb.append(widthComponent);
      stb.append(">Type</td>\n");
      if(showAlias)
        stb.append("<td class=\"td_center\" width=\"25%\">Alias</td>\n");
      stb.append("<td class=\"td_center\">Value</td>\n</tr>");
      boolean showColor = true;
      while(it.hasNext())
      {
        Param nextParam = (Param)it.next();
        stb.append("<tr class=\"td_bg1\">\n<td>");
        stb.append(nextParam.getName());
        stb.append("</td>\n<td>");
        stb.append(nextParam.getTypeString());
        stb.append("</td>\n<td>");
        if(showAlias)
        {
          if(nextParam.getAlias() == null)
            stb.append("None");
          else
            stb.append(nextParam.getAlias());
          stb.append("</td>\n<td>");
        }
        if(nextParam.getValue() == null)
          stb.append("None");
        else
          stb.append(nextParam.getValue());
        stb.append("</td>\n</tr>\n");
      }
      return stb.toString();
    } %>

<% String name = (String)request.getParameter("name");
   String type = (String)request.getParameter("type");
   boolean isComplex = false;
   Entity ent = null;
   if(type.equalsIgnoreCase("JobUnit"))
     ent = com.oval.foundation.container.JobUnitContainer.findJobUnitMeta(name);
   else
   {
     if(type.equalsIgnoreCase("Condition"))
       ent = com.oval.foundation.container.ConditionContainer.findConditionMeta(name);
     else
     {
       isComplex = true;
       if(type.equalsIgnoreCase("Component"))
         ent = com.oval.foundation.container.ComponentContainer.findComponentMeta(name);
       else
       {
         if(type.equalsIgnoreCase("Job"))
           ent = com.oval.foundation.container.JobContainer.findJobMeta(name);
       }
     }
   } %>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/chinese/csscontent.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td background="images/chinese/title_bg.gif"><img src="images/chinese/title_bg.gif" width="3" height="29"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="10%" class="red_title">Name:</td>
    <td><%=JspHelper.filterNull( name )%></td>
  </tr>
  <tr> 
    <td class="red_title">Type:</td>
    <td><%=JspHelper.filterNull( type )%></td>
  </tr>
  <tr> 
    <td class="red_title">Transaction Type:</td>
      <td><%=JspHelper.filterNull( Constants.getTxTypeString(ent.getTxType()) )%></td>
  </tr>
  <tr> 
    <td class="td_bg_row">&nbsp;</td>
    <td class="td_bg_row">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<script>
  function toggleCreate()
  {
    if(createHide.style.display=='none')
    {
      createHide.style.display = 'inline';
      createShow.style.display = 'none';
    }
    else
    {
      createShow.style.display = 'inline';
      createHide.style.display = 'none';
    }
  }
</script>
<tbody id="createHide" onclick="toggleCreate()" style="display:inline;">
  <tr> 
    <td colspan="3" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
      <%=JspHelper.filterNull( ent.getCreateParamSize() )%> Creation Parameter<%if(ent.getCreateParamSize() != 1){%>s<%}%>
    </td>
  </tr>
</tbody>
<tbody id="createShow" onclick="toggleCreate()" style="display:none;">
  <tr> 
    <td colspan="3" class="td_title_bg"><img src="images/chinese/arrow2.gif"> 
      Creation Parameters</td>
  </tr>
  
  <% if(ent.getCreateParamSize() > 0)
       { %>
       <%=JspHelper.filterNull( showParameters(ent.getCreateParams(), false) )%>
    <% }
       else
       { %>
       <tr>
         <td colspan="3">
         None
         </td>
       </tr>
    <% } %>
</tbody>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
<script>
  function toggleReturn()
  {
    if(returnHide.style.display=='none')
    {
      returnHide.style.display = 'inline';
      returnShow.style.display = 'none';
    }
    else
    {
      returnShow.style.display = 'inline';
      returnHide.style.display = 'none';
    }
  }
</script>
<tbody id="returnHide" onclick="toggleReturn()" style="display:inline;">
  <tr> 
    <td colspan="3" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
      <%=JspHelper.filterNull( ent.getReturnParamSize() )%> Return Parameter<%if(ent.getReturnParamSize() != 1){%>s<%}%>
    </td>
  </tr>
</tbody>
<tbody id="returnShow" onclick="toggleReturn()" style="display:none;">
  <tr> 
    <td colspan="3" class="td_title_bg"><img src="images/chinese/arrow2.gif"> 
      Return Parameters </td>
  </tr>
  <% if(ent.getReturnParamSize() > 0)
       { %>
       <%=JspHelper.filterNull( showParameters(ent.getReturnParams(), false) )%>
    <% }
       else
       { %>
       <tr>
         <td colspan="3">
         None
         </td>
       </tr>
    <% } %>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td rowspan="2" bgcolor="999999" width="1"></td>
    <td height="12">&nbsp;</td>
    <td rowspan="2" width="13"><img src="images/chinese/corner.gif"></td>
  </tr>
  <tr> 
    <td bgcolor="999999" height="1"></td>
  </tr>
  <tr> 
    <td height="10" colspan="3"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td height="10"></td>
    <td></td>
  </tr>
</table>


<% if(isComplex)
   { %>
<script>
    function toggleComponents()
    {
      if(componentHide.style.display=='none')
      {
        componentHide.style.display = 'inline';
        componentShow.style.display='none';
      }
      else
      {
        componentHide.style.display = 'none';
        componentShow.style.display='inline';
      }
    }
</script>
<div id="componentHide" style="display:inline;" onclick="toggleComponents()">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
  <tr> 
    <td colspan="2" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
      Component Element Descriptions
    </td>
  </tr>
</table>
</div>
<div id="componentShow" style="display:none;">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
  <tr> 
    <td colspan="2" class="td_title_bg"  onclick="toggleComponents()"><img src="images/chinese/arrow2.gif"> 
      Component Element Descriptions
    </td>
  </tr>
  <%
     Desc startDesc = ((ComponentEntity)ent).getStart();
        Iterator descs = ((ComponentEntity)ent).getElementMetas();
        int counter = 0;
        while(descs.hasNext())
        {
          counter ++;
          boolean isStarting = false;
          String descType = "Condition";
          Desc nextDesc = (Desc)descs.next();
          if(startDesc == nextDesc)
            isStarting = true;
          if(nextDesc instanceof JobUnitDesc)
            descType = "JobUnit";
          else
            if(nextDesc instanceof ComponentDesc)
              descType = "Component";
          else
            if(nextDesc instanceof Forward)
              descType = "Forward";
              %>
  <script>
    function toggleCreate<%=JspHelper.filterNull( counter )%>()
    {
      if(createHide<%=JspHelper.filterNull( counter )%>.style.display=='none')
      {
        createHide<%=JspHelper.filterNull( counter )%>.style.display = 'inline';
        createShow<%=JspHelper.filterNull( counter )%>.style.display='none';
      }
      else
      {
        createHide<%=JspHelper.filterNull( counter )%>.style.display = 'none';
        createShow<%=JspHelper.filterNull( counter )%>.style.display='inline';
      }
    }
    function toggleReturn<%=JspHelper.filterNull( counter )%>()
    {
      if(returnHide<%=JspHelper.filterNull( counter )%>.style.display=='none')
      {
        returnHide<%=JspHelper.filterNull( counter )%>.style.display = 'inline';
        returnShow<%=JspHelper.filterNull( counter )%>.style.display='none';
      }
      else
      {
        returnHide<%=JspHelper.filterNull( counter )%>.style.display = 'none';
        returnShow<%=JspHelper.filterNull( counter )%>.style.display='inline';
      }
    }
    
    function toggleRow<%=JspHelper.filterNull( counter )%>()
    {
      if(rowHide<%=JspHelper.filterNull( counter )%>.style.display=='none')
      {
        rowHide<%=JspHelper.filterNull( counter )%>.style.display = 'inline';
        rowShow<%=JspHelper.filterNull( counter )%>.style.display='none';
      }
      else
      {
        rowHide<%=JspHelper.filterNull( counter )%>.style.display = 'none';
        rowShow<%=JspHelper.filterNull( counter )%>.style.display='inline';
      }
    }
</script>
<a name="<%=JspHelper.filterNull( nextDesc.getName() )%>"><%-- --%></a>
<tbody id="rowHide<%=JspHelper.filterNull( counter )%>" style="display:inline;" onclick="toggleRow<%=JspHelper.filterNull( counter )%>()">
  <tr class="td_bg_row">
    <td class="td_center">
      <%=JspHelper.filterNull( descType )%>
    </td>
    <td class="td_center">
      <%=JspHelper.filterNull( nextDesc.getName() )%> <img src="images/chinese/arrow3.gif"> 
    </td>
  </tr>
</tbody>
<tbody id="rowShow<%=JspHelper.filterNull( counter )%>" style="display:none;">
<tr class="td_bg_row">
  
  <td class="td_center" onclick="toggleRow<%=JspHelper.filterNull( counter )%>()">
    <%=JspHelper.filterNull( descType )%><br><%=JspHelper.filterNull( nextDesc.getName() )%> <img src="images/chinese/arrow2.gif"> 
  </td>
  <td>
    <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
      <tr class="td_bg_row"> 
        <td class="td_center" width="16%">
          Reference:
        </td>
        <% if(nextDesc.getEntityRef() != null)
           { %>
        <td class="td_center" width="84%"> 
          <div align="left">
            <a href="showEntity.jsp?nocache=&type=<%=JspHelper.filterNull( descType )%>&name=<%=JspHelper.filterNull( nextDesc.getEntityRef().getName() )%>">
            <%=JspHelper.filterNull( nextDesc.getEntityRef().getName() )%>
            </a>
          </div>
        </td>
        <% }
           else
           { %>
        <td class="td_center" width="84%">
          None
        </td>
        <% } %>
      </tr>
      <tr class="td_bg1">
        <td colspan="2">
          <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
          <tbody id="createHide<%=JspHelper.filterNull( counter )%>" style="display:inline">
            <tr onclick="toggleCreate<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
                 <%=JspHelper.filterNull( nextDesc.getCreateParamSize() )%> Creation Parameter<%if(nextDesc.getCreateParamSize() != 1){%>s<%}%>
              </td>
            </tr>
          </tbody>
          <tbody id="createShow<%=JspHelper.filterNull( counter )%>" style="display:none">
            <tr onclick="toggleCreate<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg">
                <img src="images/chinese/arrow2.gif"> 
                Creation Parameters
              </td>
            </tr>
          <% if(nextDesc.getCreateParamSize() > 0)
             { %>
             <%=JspHelper.filterNull( showParameters(nextDesc.getCreateParams(), true) )%>
          <% }
             else
             { %>
            <tr>
              <td colspan="4">
                None
              </td>
            </tr>
          <% } %>
          </tbody>
          </table>
        </td>
      </tr>
      <tr class="td_bg1">
        <td colspan="2">
          <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
          <tbody id="returnHide<%=JspHelper.filterNull( counter )%>" style="display:inline">
            <tr onclick="toggleReturn<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
                 <%=JspHelper.filterNull( nextDesc.getReturnParamSize() )%> Return Parameter<%if(nextDesc.getReturnParamSize() != 1){%>s<%}%>
              </td>
            </tr>
          </tbody>
          <tbody id="returnShow<%=JspHelper.filterNull( counter )%>" style="display:none">
            <tr onclick="toggleReturn<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg">
                <img src="images/chinese/arrow2.gif"> 
                Return Parameters
              </td>
            </tr>
          <% if(nextDesc.getReturnParamSize() > 0)
             { %>
             <%=JspHelper.filterNull( showParameters(nextDesc.getReturnParams(), true) )%>
          <% }
             else
             { %>
            <tr>
              <td colspan="4">
                None
              </td>
            </tr>
          <% } %>
          </tbody>
          </table>
        </td>
      </tr>
      <tr class="td_bg1">
        <td width="16%" class="td_center">Transaction Type:</td>
        <td width="84%"><%=JspHelper.filterNull( Constants.getTxTypeString(nextDesc.getTxType()) )%></td>
      </tr>
   <% if(descType.equals("JobUnit"))
      { %>
      <tr class="td_bg1">
        <td width="16%" class="td_center">
          Next Element
        </td>
        <td width="84%">
          <a href="#<%=JspHelper.filterNull( ((JobUnitDesc)nextDesc).getStep().getName() )%>">
            <%=JspHelper.filterNull( ((JobUnitDesc)nextDesc).getStep().getName() )%>
          </a>
        </td>
      </tr>
    <% }
       else if(!(descType.equals("Forward")))
       {
         HashMap steps = new HashMap();
         if(descType.equals("Condition"))
           steps = ((ConditionDesc)nextDesc).getSteps();
         else
           steps = ((ComponentDesc)nextDesc).getSteps();
         Iterator sit = steps.keySet().iterator();
         %>
       <script>
         function toggleSteps<%=JspHelper.filterNull( counter )%>()
         {
           if(stepsHide<%=JspHelper.filterNull( counter )%>.style.display=='none')
           {
             stepsHide<%=JspHelper.filterNull( counter )%>.style.display = 'inline';
             stepsShow<%=JspHelper.filterNull( counter )%>.style.display='none';
           }
           else
           {
             stepsHide<%=JspHelper.filterNull( counter )%>.style.display = 'none';
             stepsShow<%=JspHelper.filterNull( counter )%>.style.display='inline';
           }
         }
       </script>
       <tr class="td_bg1">
        <td colspan="2">
          <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
          <tbody id="stepsHide<%=JspHelper.filterNull( counter )%>" style="display:inline">
            <tr onclick="toggleSteps<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg"><img src="images/chinese/arrow3.gif"> 
                 Possible Outgoing Steps
              </td>
            </tr>
          </tbody>
          <tbody id="stepsShow<%=JspHelper.filterNull( counter )%>" style="display:none">
            <tr onclick="toggleSteps<%=JspHelper.filterNull( counter )%>()"> 
              <td colspan="4" class="td_title_bg">
                <img src="images/chinese/arrow2.gif"> 
                Possible Outgoing Steps
              </td>
            </tr>
            <% while(sit.hasNext())
               {
                 String nextKey = (String)sit.next(); %>
            <tr>
              <td valign="top"  bgcolor="#DCDCDC">
                <%=JspHelper.filterNull( nextKey )%>
              </td>
              <td>
                <a href="#<%=JspHelper.filterNull( ((Step)steps.get(nextKey)).getName() )%>">
                  <%=JspHelper.filterNull( ((Step)steps.get(nextKey)).getName() )%>
                </a>
              </td>
            </tr>     
            <% } %>
          </tbody>
          </table>
        </td>
      </tr>
    <% } %>
    </table>
  </td>
</tr>
</tbody>
  <% } %>
</table>
</div>
<% } %>
</body>
</html>

